﻿<UserControl x:Class="Ags.MonsterTools.Guids.GuidView"
             xmlns="http://schemas.microsoft.com/winfx/2006/xaml/presentation"
             xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml"
             xmlns:mc="http://schemas.openxmlformats.org/markup-compatibility/2006" 
             xmlns:d="http://schemas.microsoft.com/expression/blend/2008" 
             mc:Ignorable="d" 
             d:DesignHeight="480" d:DesignWidth="640" Background="White"
             xmlns:local="clr-namespace:Ags.MonsterTools.Guids"
             Name="GuidUserControl">
    <UserControl.Resources>
        <ResourceDictionary>
            <ResourceDictionary.MergedDictionaries>
                <ResourceDictionary>
                    <local:StringToIntConverter x:Key="IntConverter"></local:StringToIntConverter>
                    <Style x:Key="PanelStyle" TargetType="StackPanel">
                        <Setter Property="Margin" Value="5"></Setter>
                    </Style>
                    <Style x:Key="BtnStyle" TargetType="Button">
                        <Setter Property="Margin" Value="5,0,5,0"></Setter>
                        <Setter Property="Width" Value="60"></Setter>
                        <Setter Property="Height" Value="60"></Setter>
                        <Setter Property="OverridesDefaultStyle" Value="True"/>
                        <Setter Property="Template">
                            <Setter.Value>
                                <ControlTemplate TargetType="Button">
                                    <ContentPresenter Name="ContentImage"  ContentTemplate="{TemplateBinding Content}"/>
                                    <ControlTemplate.Triggers>
                                        <Trigger Property="IsMouseOver" Value="True">
                                            <Setter TargetName="ContentImage" Property="Opacity" Value="0.5"></Setter>
                                        </Trigger>
                                        <Trigger Property="IsPressed" Value="True">
                                            <Setter TargetName="ContentImage" Property="Opacity" Value="0.9"></Setter>
                                        </Trigger>
                                        <Trigger Property="IsEnabled" Value="False">
                                            <Setter TargetName="ContentImage" Property="Opacity" Value="0.2"></Setter>
                                        </Trigger>
                                    </ControlTemplate.Triggers>
                                </ControlTemplate>
                            </Setter.Value>
                        </Setter>
                    </Style>

                    <Style x:Key="LblStyleHead" TargetType="Label">
                        <Setter Property="FontWeight" Value="SemiBold"></Setter>
                        <Setter Property="Margin" Value="0,5,0,5"></Setter>
                    </Style>
                    <Style x:Key="TbStyle" TargetType="TextBox">
                        <Setter Property="VerticalContentAlignment" Value="Center"></Setter>
                        <Setter Property="Margin" Value="5,0,5,0"></Setter>
                        <Setter Property="Height" Value="25"></Setter>
                    </Style>

                    <Style x:Key="GuidTbStyle" TargetType="TextBox">
                        <Setter Property="FontSize" Value="16"></Setter>
                    </Style>

                    <Style x:Key="ListBoxStyle" TargetType="ListBox">
                        <Setter Property="Margin" Value="5"></Setter>
                        <Setter Property="ItemTemplate">
                            <Setter.Value>
                                <DataTemplate>
                                    <Border CornerRadius="10" BorderThickness="1" BorderBrush="Gainsboro" 
                                            Margin="3"
                                            Background="LightGreen">
                                        <Grid Height="30" Margin="5">
                                            <Grid.ColumnDefinitions>
                                                <ColumnDefinition Width="Auto"></ColumnDefinition>
                                                <ColumnDefinition Width="*"></ColumnDefinition>
                                                <ColumnDefinition Width="Auto"></ColumnDefinition>
                                            </Grid.ColumnDefinitions>
                                            <Image Grid.Column="0" Source="/Ags.MonsterTools.Guids;component/Images/key.png" Width="12" Height="26" Margin="5,0,5,0"></Image>
                                            <TextBox Grid.Column="1" Text="{Binding Path=., Mode=OneWay}" 
                                                     IsReadOnly="True" 
                                                     HorizontalAlignment="Stretch"
                                                     Style="{StaticResource GuidTbStyle}"></TextBox>
                                            <Button Grid.Column="2" Command="{Binding ElementName=GuidUserControl, Path=DataContext.CopyClipboardCommand}"
                                                CommandParameter="{Binding RelativeSource={RelativeSource AncestorType={x:Type ListBoxItem}}, Path=Content}"
                                                Margin="10,0,5,0"
                                                Style="{DynamicResource MetroCircleButtonStyle}"
                                                Width="28"
                                                Height="28"
                                                ToolTip="Copy to clipboard">
                                                <Button.Content>
                                                    <Image Source="/Ags.MonsterTools.Guids;component/Images/clipboard.png" Width="12" Height="26"></Image>
                                                </Button.Content>
                                            </Button>
                                        </Grid>
                                    </Border>
                                </DataTemplate>
                            </Setter.Value>
                        </Setter>
                    </Style>
                </ResourceDictionary>
            </ResourceDictionary.MergedDictionaries>
        </ResourceDictionary>

    </UserControl.Resources>
    <Grid>
        <Grid.RowDefinitions>
            <RowDefinition Height="Auto"></RowDefinition>
            <RowDefinition></RowDefinition>
        </Grid.RowDefinitions>
        <Grid.ColumnDefinitions>
            <ColumnDefinition Width="Auto"></ColumnDefinition>
            <ColumnDefinition></ColumnDefinition>
        </Grid.ColumnDefinitions>

        <!--Control-->
        <StackPanel Orientation="Horizontal" Style="{StaticResource PanelStyle}" Grid.Column="0" Grid.Row="0">
            <StackPanel Orientation="Vertical">
                <Label Content="AMOUNT" Style="{StaticResource LblStyleHead}"></Label>
                <TextBox Text="{Binding Amount, Converter={StaticResource IntConverter}, UpdateSourceTrigger=PropertyChanged}" Style="{StaticResource TbStyle}"></TextBox>
            </StackPanel>
            <Button Grid.Row="0" Grid.Column="1" Style="{StaticResource BtnStyle}" Command="{Binding GenerateGuidsCommand}">
                <Image Source="Images/Process.png" Width="32" Height="32"></Image>
            </Button>
        </StackPanel>
        <!--List-->
        <ListBox Style="{StaticResource ListBoxStyle}" 
                 Grid.Row="1" Grid.Column="0" Grid.ColumnSpan="2" 
                 ItemsSource="{Binding GuidList}"
                 ScrollViewer.VerticalScrollBarVisibility="Visible" SelectionMode="Extended">
        </ListBox>
    </Grid>
</UserControl>
